<template>
<div>
  app.vue
  <br><br>
  <button @click="addScript">插入Script</button>
  <button @click="addLink">插入Link</button>
  <button @click="addCSS">插入引用其他资源的CSS文件</button>
  <button @click="addImg">插入Img</button>
  <button @click="addLocalImg">插入Base64图片</button>
  <button @click="addXHR">发送XMLHTTPRequest</button>
  <button @click="addErrXHR">发送异常的XMLHTTPRequest</button>
  <br><br>
</div>
</template>

<script>
export default {
  name: 'bar',
  methods: {
    addScript() {
      const script = document.createElement('script');
      script.src = 'http://172.15.4.131:4873/-/static/vendors.064cfdd8107ff39d68ca.js';
      document.head.appendChild(script);
    },
    addLink() {
      const link = document.createElement('link');
      link.type = 'text/css';
      link.rel = 'stylesheet';
      link.href = 'http://172.15.4.131:4873/-/static/0.style.b3d2b69b057068c678ca.css';
      document.head.appendChild(link);
    },
    addCSS() {
      const link = document.createElement('link');
      link.type = 'text/css';
      link.rel = 'stylesheet';
      link.href = '/a.css';
      document.head.appendChild(link);
    },
    addImg() {
      const img = document.createElement('img');
      const size = Math.ceil(Math.random() * 100);
      img.src = `https://p2.music.126.net/vB84V9nQ5PpwGt6oDuhxqg==/7984653441988970.jpg?param=${size}y${size}`;
      document.body.appendChild(img);
    },
    addLocalImg() {
      const img = document.createElement('img');
      document.body.appendChild(img);
      img.src = '';
    },
    addXHR() {
      const xhr = new XMLHttpRequest();
      xhr.open('get', `/index.html?t=${Date.now()}`);
      xhr.send();
    },
    addErrXHR() {
      const xhr = new XMLHttpRequest();
      xhr.open('post', '/not-found');
      xhr.send(JSON.stringify({}));
    },
  },
};
</script>
<style>

</style>
